// @ts-ignore
import Client from 'ali-oss';

const generateUniqueFileName = () => {
  var timestamp = new Date().getTime();
  var randomNumber = Math.floor(Math.random() * (999 - 100 + 1) + 100);
  var fileName = "file_" + timestamp + "_" + randomNumber;
  return fileName;
}

export const AliOSS = new Client({
  region: 'oss-cn-shenzhen',
  accessKeyId: 'LTAI4G4eUeeA1927TvTeb193',
  accessKeySecret: 'MXrz2Q1fqdGsmKKTZUA8aoxaRwzw6P',
  bucket: 'gxmanager'
});

export const UploadPut = (params: any) => AliOSS.put<any>(`fkyy_admin/${generateUniqueFileName()}`, params.file);